package com.nage.components.touch;

import android.util.Log;

import com.nage.engine.GameGraph;
import com.nage.engine.GameObject;

public class RemoveSquareButton extends Touchable {
	// Defines an area of screen that when pressed will destroy a shape on the screen

	
	public RemoveSquareButton(GameObject p) {
		super(p);
		type = REMOVE_SQAURE_BUTTON;

	}

	@Override
	public void onTouch() {
		GameGraph graph = parent.parent; // the game graph.
		
		// get the last object from the game graph, check if it is a random button and if it is,
		// tell it to be removed.
		GameObject obj = graph.getLastObject();
		if(obj==null) {
			return;
		}
		if (obj.m_Name.startsWith("RandomSquare")) {
			graph.removeWhenPossible(obj);
		}
		Log.v("RemoveSquare", "Removing square from screen by GameObject: "+parent.m_Name);		
	}

}
